<?php
  	class pager{
		protected $_link;
		public function set_link($link){
			$this->_link = $link;
		}
		public function start(){
			if(isset($_GET['start'])){
				$start = $_GET['start'];
			}else{
				$start = 0;
			}
			return $start;
		}
		public function page($total,$limit){
			if(isset($_GET['pages'])){
				$page = $_GET['pages'];
			}else{
				$page = ceil($total/$limit);
			}
			return $page;
		}
		public function listpage($pages,$start,$limit){
			$list = "";
			if($pages > 1){
				$curpage = ($start/$limit) + 1;
                if($curpage + 3 > $pages){
                    $maxindex = $pages;
                }else{
                    $maxindex = $curpage +3;
                }
                if (($curpage - 3) < 1){
                    $minindex = 1;
                }else{
                    $minindex = $curpage - 3;
                }
				if($curpage != 1){
					$star = $start - $limit;
					$list.= "<a href='javascript:void(0)' name='$star' id='$pages' class='link prev' title='Prev'>Prev</a>";
				}
				for($i = $minindex; $i <= $maxindex; $i++){
					if($curpage == $i){
						$list.= "<span class='active'>".$i."</span>";
					}else{
						$star = ($i - 1)*$limit;
						$list.= "<a href='javascript:void(0)' name='$star' id='$pages' class='link'>".$i."</a>";
					}
				}
				if($curpage != $pages){
					$star = $start + $limit;
					$list.= "<a href='javascript:void(0)' name='$star' id='$pages' class='link next' title='Next'>Next</a>";
				}
				return $list;
			}
		}

		public function listpages($pages,$start,$limit,$type){
			$list = "";
			if($pages > 1){
				$curpage = ($start/$limit) + 1;
                if($curpage + 3 > $pages){
                    $maxindex = $pages;
                }else{
                    $maxindex = $curpage +3;
                }
                if (($curpage - 3) < 1){
                    $minindex = 1;
                }else{
                    $minindex = $curpage - 3;
                }
				if($curpage != 1){
					$star = $start - $limit;
					$list.= "<a href='javascript:void(0)' rel='$type' name='$star' id='$pages' class='links' title='Prev'>
					<img src='".base_url()."public/images/arrow_page_05.jpg' border='0'width='22' height='24' class='fl mgl3'/>
					</a>";
				}
				for($i=$minindex;$i<=$maxindex;$i++){
					if($curpage == $i){
						$list.= "<span class='active bder_rdus3 mgt1 fl apage mgl3'>".$i."</span>";
					}else{
						$star = ($i - 1)*$limit;
						$list.= "<a href='javascript:void(0)' rel='$type' name='$star' id='$pages' class='links bder_rdus3 mgt1 fl apage mgl3'>".$i."</a>";
					}
				}
				if($curpage != $pages){
					$star = $start + $limit;
					$list.= "<a href='javascript:void(0)' rel='$type' name='$star' id='$pages' class='links next' title='Next'>
					<img src='".base_url()."public/images/arrow_page_07.jpg' border='0' width='22' height='24' class='fl mgl3'/>
					</a>";
				}
				return $list;
			}
		}
          public function listpageregion($pages,$start,$limit,$type){
              $list = "";
              if($pages > 1){

                  $curpage = ($start/$limit) + 1;
                  if($curpage + 3 > $pages){
                      $maxindex = $pages;
                  }else{
                      $maxindex = $curpage +3;
                  }
                  if (($curpage - 3) < 1){
                      $minindex = 1;
                  }else{
                      $minindex = $curpage - 3;
                  }
                  if($curpage != 1){
                      $star = $start - $limit;
                      $list.= "<a href='javascript:void(0)' rel='$type' name='$star' id='$pages' onclick='pageregion(this);' class='linkhotel' title='Prev'>
					<img src='".base_url()."public/images/arrow_page_05.jpg' border='0'width='22' height='24' class='fl mgl3'/>
					</a>";
                  }
                  for($i=$minindex;$i<=$maxindex;$i++){
                      if($curpage == $i){
                          $list.= "<span class='active bder_rdus3 mgt1 fl apage mgl3'>".$i."</span>";
                      }else{
                          $star = ($i - 1)*$limit;
                          $list.= "<a href='javascript:void(0)' rel='$type' name='$star' id='$pages' onclick='pageregion(this);' class='linkhotel bder_rdus3 mgt1 fl apage mgl3'>".$i."</a>";
                      }
                  }
                  if($curpage != $pages){
                      $star = $start + $limit;
                      $list.= "<a href='javascript:void(0)' rel='$type' name='$star' id='$pages' onclick='pageregion(this);' class='linkhotel next' title='Next'>
					<img src='".base_url()."public/images/arrow_page_07.jpg' border='0' width='22' height='24' class='fl mgl3'/>
					</a>";
                  }
                  return $list;
              }
          }
          public function listpagehotel($pages,$start,$limit,$type){
              $list = "";
              if($pages > 1){

                  $curpage = ($start/$limit) + 1;
                  if($curpage + 3 > $pages){
                      $maxindex = $pages;
                  }else{
                      $maxindex = $curpage +3;
                  }
                  if (($curpage - 3) < 1){
                      $minindex = 1;
                  }else{
                      $minindex = $curpage - 3;
                  }
                  if($curpage != 1){
                      $star = $start - $limit;
                      $list.= "<a href='javascript:void(0)' rel='$type' name='$star' id='$pages' onclick='pagehotel(this);' class='linkhotel' title='Prev'>
					<img src='".base_url()."public/images/arrow_page_05.jpg' border='0'width='22' height='24' class='fl mgl3'/>
					</a>";
                  }
                  for($i=$minindex;$i<=$maxindex;$i++){
                      if($curpage == $i){
                          $list.= "<span class='active bder_rdus3 mgt1 fl apage mgl3'>".$i."</span>";
                      }else{
                          $star = ($i - 1)*$limit;
                          $list.= "<a href='javascript:void(0)' rel='$type' name='$star' id='$pages' onclick='pagehotel(this);' class='linkhotel bder_rdus3 mgt1 fl apage mgl3'>".$i."</a>";
                      }
                  }
                  if($curpage != $pages){
                      $star = $start + $limit;
                      $list.= "<a href='javascript:void(0)' rel='$type' name='$star' id='$pages' onclick='pagehotel(this);' class='linkhotel next' title='Next'>
					<img src='".base_url()."public/images/arrow_page_07.jpg' border='0' width='22' height='24' class='fl mgl3'/>
					</a>";
                  }
                  return $list;
              }
          }
          public function listpageall($pages,$start,$limit, $destination, $type){
              $list = "";
              if($pages > 1){
                  $curpage = ($start/$limit) + 1;
                  if($curpage + 3 > $pages){
                      $maxindex = $pages;
                  }else{
                      $maxindex = $curpage +3;
                  }
                  if (($curpage - 3) < 1){
                      $minindex = 1;
                  }else{
                      $minindex = $curpage - 3;
                  }
                  if($curpage != 1){
                      $star = $start - $limit;
                      $list.= "<a href='javascript:void(0)' rel2='$destination' rel='$type' name='$star' id='$pages' onclick='pages(this);' class='linkhotel' title='Prev'>
					<img src='".base_url()."public/images/arrow_page_05.jpg' border='0'width='22' height='24' class='fl mgl3'/>
					</a>";
                  }
                  for($i=$minindex;$i<=$maxindex;$i++){
                      if($curpage == $i){
                          $list.= "<span class='active bder_rdus3 mgt1 fl apage mgl3'>".$i."</span>";
                      }else{
                          $star = ($i - 1)*$limit;
                          $list.= "<a href='javascript:void(0)' rel2='$destination' rel='$type' name='$star' id='$pages' onclick='pages(this);' class='linkhotel bder_rdus3 mgt1 fl apage mgl3'>".$i."</a>";
                      }
                  }
                  if($curpage != $pages){
                      $star = $start + $limit;
                      $list.= "<a href='javascript:void(0)' rel2='$destination' rel='$type' name='$star' id='$pages' onclick='pages(this);' class='linkhotel next' title='Next'>
					<img src='".base_url()."public/images/arrow_page_07.jpg' border='0' width='22' height='24' class='fl mgl3'/>
					</a>";
                  }
                  return $list;
              }
          }
          public function listpage2($pages,$start,$limit, $destination,$region){
              $list = "";
              if($pages > 1){
                  $curpage = ($start/$limit) + 1;
                  if($curpage + 3 > $pages){
                      $maxindex = $pages;
                  }else{
                      $maxindex = $curpage +3;
                  }
                  if (($curpage - 3) < 1){
                      $minindex = 1;
                  }else{
                      $minindex = $curpage - 3;
                  }
                  if($curpage != 1){
                      $star = $start - $limit;
                      $list.= "<a href='javascript:void(0)'  rel2='$region' rel='$destination' name='$star' id='$pages' onclick='pagers(this);' class='linkhotel' title='Prev'>
					<img src='".base_url()."public/images/arrow_page_05.jpg' border='0'width='22' height='24' class='fl mgt2 mgl3'/>
					</a>";
                  }
                  for($i=$minindex;$i<=$maxindex;$i++){
                      if($curpage == $i){
                          $list.= "<span class='active bder_rdus3 mgt1 fl apage mgl3'>".$i."</span>";
                      }else{
                          $star = ($i - 1)*$limit;
                          $list.= "<a href='javascript:void(0)' rel2='$region' rel='$destination' name='$star' id='$pages' onclick='pagers(this);' class='linkhotel bder_rdus3 mgt1 fl apage mgl3'>".$i."</a>";
                      }
                  }
                  if($curpage != $pages){
                      $star = $start + $limit;
                      $list.= "<a href='javascript:void(0)' rel2='$region' rel='$destination' name='$star' id='$pages' onclick='pagers(this);' class='linkhotel next' title='Next'>
					<img src='".base_url()."public/images/arrow_page_07.jpg' border='0' width='22' height='24' class='fl mgt2 mgl3'/>
					</a>";
                  }
                  return $list;
              }
          }
          public function listpage3($pages,$start,$limit, $destination,$region, $type){
              $list = "";
              if($pages > 1){
                  $curpage = ($start/$limit) + 1;
                  if($curpage + 3 > $pages){
                      $maxindex = $pages;
                  }else{
                      $maxindex = $curpage +3;
                  }
                  if (($curpage - 3) < 1){
                      $minindex = 1;
                  }else{
                      $minindex = $curpage - 3;
                  }
                  if($curpage != 1){
                      $star = $start - $limit;
                      $list.= "<a href='javascript:void(0)' rel3='$region' rel2='$destination' rel='$type' name='$star' id='$pages' onclick='pages(this);' class='linkhotel' title='Prev'>
					<img src='".base_url()."public/images/arrow_page_05.jpg' border='0'width='22' height='24' class='fl mgl3'/>
					</a>";
                  }
                  for($i=$minindex;$i<=$maxindex;$i++){
                      if($curpage == $i){
                          $list.= "<span class='active bder_rdus3 mgt1 fl apage mgl3'>".$i."</span>";
                      }else{
                          $star = ($i - 1)*$limit;
                          $list.= "<a href='javascript:void(0)' rel3='$region' rel2='$destination' rel='$type' name='$star' id='$pages' onclick='pages(this);' class='linkhotel bder_rdus3 mgt1 fl apage mgl3'>".$i."</a>";
                      }
                  }
                  if($curpage != $pages){
                      $star = $start + $limit;
                      $list.= "<a href='javascript:void(0)' rel3='$region' rel2='$destination' rel='$type' name='$star' id='$pages' onclick='pages(this);' class='linkhotel next' title='Next'>
					<img src='".base_url()."public/images/arrow_page_07.jpg' border='0' width='22' height='24' class='fl mgl3'/>
					</a>";
                  }
                  return $list;
              }
          }
          public function listpage4($pages,$start,$limit, $destination,$region, $type, $tour){
              $list = "";
              if($pages > 1){
                  $curpage = ($start/$limit) + 1;
                  if($curpage + 3 > $pages){
                      $maxindex = $pages;
                  }else{
                      $maxindex = $curpage +3;
                  }
                  if (($curpage - 3) < 1){
                      $minindex = 1;
                  }else{
                      $minindex = $curpage - 3;
                  }
                  if($curpage != 1){
                      $star = $start - $limit;
                      $list.= "<a href='javascript:void(0)' rel4='$tour' rel3='$region' rel2='$destination' rel='$type' name='$star' id='$pages' onclick='pages(this);' class='linkhotel' title='Prev'>
					<img src='".base_url()."public/images/arrow_page_05.jpg' border='0'width='22' height='24' class='fl mgl3'/>
					</a>";
                  }
                  for($i=$minindex;$i<=$maxindex;$i++){
                      if($curpage == $i){
                          $list.= "<span class='active bder_rdus3 mgt1 fl apage mgl3'>".$i."</span>";
                      }else{
                          $star = ($i - 1)*$limit;
                          $list.= "<a href='javascript:void(0)' rel4='$tour' rel3='$region' rel2='$destination' rel='$type' name='$star' id='$pages' onclick='pages(this);' class='linkhotel bder_rdus3 mgt1 fl apage mgl3'>".$i."</a>";
                      }
                  }
                  if($curpage != $pages){
                      $star = $start + $limit;
                      $list.= "<a href='javascript:void(0)' rel4='$tour' rel3='$region' rel2='$destination' rel='$type' name='$star' id='$pages' onclick='pages(this);' class='linkhotel next' title='Next'>
					<img src='".base_url()."public/images/arrow_page_07.jpg' border='0' width='22' height='24' class='fl mgl3'/>
					</a>";
                  }
                  return $list;
              }
          }
		public function listpage_s($pages,$start,$limit,$destina,$holiday,$dura){
			$list = "";
			if($pages > 1){
				$curpage = ($start/$limit) + 1;
                if($curpage + 3 > $pages){
                    $maxindex = $pages;
                }else{
                    $maxindex = $curpage +3;
                }
                if (($curpage - 3) < 1){
                    $minindex = 1;
                }else{
                    $minindex = $curpage - 3;
                }
				if($curpage != 1){
					$star = $start - $limit;
					$list.= "<a href='".base_url()."home/search?destinations=$destina&holiday=$holiday&duration=$dura&pages=$pages&start=$star' class='links prev' title='Prev'>Prev</a>";
				}
				for($i=$minindex;$i<=$maxindex;$i++){
					if($curpage == $i){
						$list.= "<span class='active'>".$i."</span>";
					}else{
						$star = ($i - 1)*$limit;
						$list.= "<a href='".base_url()."home/search?destinations=$destina&holiday=$holiday&duration=$dura&pages=$pages&start=$star' class='links'>".$i."</a>";
					}
				}
				if($curpage != $pages){
					$star = $start + $limit;
					$list.= "<a href='".base_url()."home/search?destinations=$destina&holiday=$holiday&duration=$dura&pages=$pages&start=$star' class='links next' title='Next'>Next</a>";
				}
				return $list;
			}
		}
	}
?>
